package com.Questions.elseQuestion;


/**
 * 给植物浇水
 */
public class leetcode2079 {
    public int wateringPlants(int[] plants, int capacity) {
        int ans = 0;
        int cur = capacity;
        for (int i = 0; i < plants.length; i++) {
            if (cur < plants[i]) {
                // 不足 需要返回然后继续
                ans += i * 2;
                cur = capacity;
            }
            cur -= plants[i];
            ans++;
        }
        return ans;
    }
}
